/************************************************************************

								Heroes IV
					  Copyright 2000, The 3DO Company

	------------------------------------------------------------------
  						 missile_type.h

	$Header: /heroes4/missile_type.h $

	$NoKeywords: $

 ************************************************************************/

#include "precompiled.h"
#include "missile_type.h"

#include "elements_of.h"
#include "enum_map.h"

static t_char_ptr_pair k_keywords[] = 
{
	{ k_missile_armageddon,		"armageddon" },
	{ k_missile_arrow,			"arrow" },
	{ k_missile_axe,			"axe" },
	{ k_missile_beam,			"beam" },
	{ k_missile_boulder,		"boulder" },
	{ k_missile_chain_lightning, "chain_lightning" },
	{ k_missile_fireball,		"fireball" },
	{ k_missile_fire_bolt,		"fire_bolt" },
	{ k_missile_heavy_bolt,		"heavy_bolt" },
	{ k_missile_ice_bolt,		"ice_bolt" },
	{ k_missile_lightning,		"lightning" },
	{ k_missile_life_force,		"life_force" },
	{ k_missile_magic,			"magic" },
	{ k_missile_magic_arrow,	"magic_arrow" },
	{ k_missile_magic_fist,		"magic_fist" },
	{ k_missile_mana,			"mana" },
	{ k_missile_pebble,			"pebble" },
	{ k_missile_potion,			"potion" },
	{ k_missile_spear,			"spear" },
	{ k_missile_spittle,		"spittle" },
	{ k_missile_thorn,			"thorn" },
};

std::string get_keyword( t_missile_type type )
{
	static t_enum_map<t_missile_type> k_keyword_map( k_keywords,
		                                             ELEMENTS_OF( k_keywords ), 
		                                             k_missile_type_count );
	return k_keyword_map[type];
}

bool        is_parabolic( t_missile_type missile )
{
	static bool initialized = false;
	static bool parabolic[k_missile_type_count];

	if (!initialized)
	{
		t_missile_type const k_parabolic[] =
		{
			k_missile_arrow,
			k_missile_axe,
			k_missile_boulder,
			k_missile_heavy_bolt,
			k_missile_pebble,
			k_missile_potion,
			k_missile_spear,
			k_missile_spittle,
			k_missile_thorn,
		};
		int i;

		memset( parabolic, false, sizeof( parabolic ));
		for (i = 0; i < ELEMENTS_OF( k_parabolic ); i++)
			parabolic[k_parabolic[i]] = true;
		initialized = true;
	}
	return parabolic[missile];
}
